package com.lht.learn.springboot.service;

import com.lht.learn.springboot.entity.User;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @author Eric
 * @version 1.0
 * @date 2019-12-24
 */
@Service
public class TestCacheService {

    @Cacheable(cacheNames = {"user"}, key="#id")
    public User getUser(Integer id) {
        System.out.println("用户id : " + id);
        User user = new User();
        user.setUsername("小明");
        user.setId(id);
        user.setAge(10);
        return user;
    }
}
